﻿#region Usings

using System.Data.Entity.ModelConfiguration;
using Rail.Net.Core.Model;

#endregion

namespace Rail.Net.Data.Configuration
{
    public class PriceSerialMap : EntityTypeConfiguration<PriceSerial>
    {
        public PriceSerialMap()
        {
            ToTable("PriceSerials");
            HasKey(priceSerial => priceSerial.Id);

            Property(priceSerial => priceSerial.TarifNumber).IsRequired();
            Property(priceSerial => priceSerial.Class).IsRequired().HasMaxLength(1);
            Property(priceSerial => priceSerial.Serial).IsRequired();
            Property(price => price.Price).IsRequired().HasPrecision(18, 2);
            Property(priceSerial => priceSerial.ValidFrom).IsRequired();
            Property(priceSerial => priceSerial.ValidTo).IsRequired();
            
            HasRequired(priceSerial => priceSerial.Ru).WithMany(ru => ru.PriceSerials);
        }
    }
}